Fix: resolve local preview server keep-alive hang by spawning per-con…#48
Fix: resolve local preview server keep-alive hang by spawning per-con…#48Adithyakp86 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
@Adithyakp86 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
The fix makes sense for the local preview server, especially with browsers opening multiple connections and exposing the single-threaded blocking issue. That said, this still only affects local development (cargo xtask serve), not the actual training content or main usage of the repo, so the impact remains limited unless it’s a common blocker for contributors. I would like to hear your thoughts @atulkhare4096 |
|
This looks good, but I am wondering whether we can format it better to better reflect that we are for the most part moving everything into a closure and spawning a thread (basically two key changes). The rest of the code is the same, but it's little difficult to tell because it looks like all the lines have changed. I think one way to do it might be to create the closure, assign it, and then simply do a |
|
Yo mane. What up doe!
…On Fri, Mar 27, 2026, 7:18 PM atulkhare4096 ***@***.***> wrote:
*atulkhare4096* left a comment (microsoft/RustTraining#48)
<#48?email_source=notifications&email_token=BYRHBNO5OUF4NYFJ3M32EST4S4D23A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUGU4DMMZTGYYKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOS2XA4S7MNXW23LFNZ2F633QMVXF6Y3MNFRWW#issuecomment-4145863360>
This looks good, but I am wondering whether we can format it better to
better reflect that we are for the most part moving everything into a
closure and spawning a thread (basically two key changes). The rest of the
code is the same, but it's little difficult to tell because it looks like
all the lines have changed.
—
Reply to this email directly, view it on GitHub
<#48?email_source=notifications&email_token=BYRHBNO5OUF4NYFJ3M32EST4S4D23A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJUGU4DMMZTGYYKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOS2XA4S7MNXW23LFNZ2F633QMVXF6Y3MNFRWW#issuecomment-4145863360>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BYRHBNNW2NV4I4FEESJSCLT4S4D23AVCNFSM6AAAAACXBKL3JSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCNBVHA3DGMZWGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
…nection threads
#42
Description
This PR resolves a local Denial of Service (DoS) behavior in the
xtaskpreview server where Keep-Alive connections indefinitely hung the browser.The local development server implemented in
cargo xtask serve(xtask/src/main.rs:cmd_serve()) was previously fully synchronous and single-threaded. It processed incoming HTTP connections sequentially with a blocking.read()call. When modern browsers attempted to load a locally served mdBook page, they opened multiple concurrent connections causing the subsequent requests to queue, stall, and artificially slow page rendering or drop CSS/JS assets.Proposed Changes
To fix this natively without adding new heavy dependencies:
std::thread::spawn).Connection: closeto the HTTP response headers to inform the browser that the socket won't be reused for Keep-Alive requests, dropping the socket cleanly.Related Issue(s)
Fixes #<ISSUE_NUMBER_HERE>
Types of changes
Checklist: